#include <stdio.h>
#include <iostream>
#include <SFML\Graphics.hpp>

#include "Application.h"
#include "Tank.h"
#include "ControllerBase.h"
#include "KeyboardController.h"
#include "Scene.h"

int main(int argc, const char* argv)
{
	cat::Application& application = cat::Application::current();
	cat::Scene scene;
	application.menu();

	sf::RenderWindow& window = application.getWindow();

	while (window.isOpen())
    {
		window.clear(sf::Color::Black);

		scene.think();
		scene.draw();

		application.getServer().think();

		cat::ControllerBase::thinkEach();

		{
			std::list<cat::Tank*>::iterator it = cat::Application::current().getTanksIteratorBegin();
			std::list<cat::Tank*>::iterator end = cat::Application::current().getTanksIteratorEnd();
			for(;it != end; ++it)
			{
				(*it)->think();
				(*it)->draw();
			}
		}

		application.getBulletFactory().think();
		application.getBulletFactory().draw();

        window.display();
    }

	return EXIT_SUCCESS;
}